package com.yulp.springboot2task.job;

import com.yulp.springboot2task.utils.DateUtil;
import org.quartz.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

/**
 */
public class SimpleQuartzJob implements Job {

    private static final Logger logger = LoggerFactory.getLogger(SimpleQuartzJob.class);

    @Override
    public void execute(JobExecutionContext context) {

        JobKey jobKey = context.getJobDetail().getKey();
        TriggerKey trkey = context.getTrigger().getKey();

        StringBuilder sb = new StringBuilder("; ");
        JobDataMap dataMap = context.getMergedJobDataMap();
        if (dataMap != null && !dataMap.isEmpty()) {
            for(Map.Entry entry : dataMap.entrySet()){
                sb.append("key: ").append(entry.getKey()).append("; value: ").append(entry.getValue());
            }
        }
        System.out.println(DateUtil.currentDateLong()+ ", 接收到任务； jobKey.getName(): "+jobKey.getName()
                +" trkey.getName():"+ trkey.getName() + sb.toString());

    }

}